import pymysql

# 连接mysql(socket)
conn = pymysql.connect(host="127.0.0.1", port=3306, user='root', passwd='', charset='utf8')
cursor = conn.cursor()

# 创建数据库(新增、删除、修改)
# 发送指令
# cursor.execute("create database study2 default charset utf8 collate utf8_general_ci")
# conn.commit()

# # 进入数据库，查看表
# cursor.execute("use mysql")
# cursor.execute("show tables")
# result = cursor.fetchall()
# print(result)

# 创建表
# cursor.execute("use study2")
# sql = """create table study33(
# id int not null primary key auto_increment,
# title varchar(128),
# content text,
# ctime datetime
# )default charset = utf8;"""
#
# cursor.execute(sql)
# conn.commit()

# 进入数据库，查看表
cursor.execute("use study2")
cursor.execute("show tables")
result = cursor.fetchall()
print(result)